﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html>
<head>

  <meta http-equiv="Content-Language" content="en-us">



  <title>IupGetAttribute</title>
  <link rel="stylesheet" type="text/css" href="../../style.css">
	<style type="text/css">
.style1 {
	text-decoration: underline;
}
.style2 {
	background-color: #CEE7FF;
}
</style>
</head>


<body>


<h2>IupGetAttribute</h2>

<p>Returns the name of an interface element attribute. See also the
<a href="../attrib_guide.html">Attributes Guide</a> section.</p>

<h3>
Parameters/Return</h3>

<pre>char *IupGetAttribute(Ihandle *<strong>ih</strong>, const char *<strong>name</strong>); [in C]<br>iup.GetAttribute(<strong>ih</strong>: ihandle, <strong>name</strong>: string) -&gt; <strong>value</strong>: string, ihandle or userdata [in Lua]

char *IupGetAttributeId(Ihandle *<strong>ih</strong>, const char *<strong>name</strong>, int <strong>id</strong>); [in C]<br>iup.GetAttributeId(<strong>ih</strong>: ihandle, <strong>name</strong>: string, <strong>id</strong>: number) -&gt; <strong>value</strong>: string, ihandle or userdata [in Lua]

char* IupGetAttributeId2(Ihandle* ih, const char* name, int <strong>lin</strong>, int <strong>col</strong>); [in C]
iup.GetAttributeId2(<strong>ih</strong>: ihandle, <strong>name</strong>: string, <strong>lin</strong>, <strong>col</strong>: number) -&gt; <strong>value</strong>: string, ihandle or userdata [in Lua] </pre>

<p><b>ih</b>: Identifier of the interface element. If
  NULL will retrieve from the global environment.<br>

  <strong>name</strong>: name of the attribute.<br>
<strong>id, lin, col</strong>: used when the attribute has additional ids.</p>

<p><span class="style1">Returns:</span> the attribute value or NULL (nil in Lua) 
if 
  the attribute is not set or does not exist.<br>

</p>


<h3>Utility Functions </h3>
<p>These functions can also be used to get attributes from the element:</p>
<pre>int    IupGetInt   (Ihandle* <strong>ih</strong>, const char* <strong>name</strong>);
int    IupGetIntInt(Ihandle*<strong> ih</strong>, const char* <strong>name</strong>, int *<strong>i1</strong>, int *<strong>i2</strong>);
int    IupGetInt2  (Ihandle* <strong>ih</strong>, const char* <strong>name</strong>);
float  IupGetFloat (Ihandle* <strong>ih</strong>, const char* <strong>name</strong>);
double IupGetDouble(Ihandle* <strong>ih</strong>, const char* <strong>name</strong>);
void   IupGetRGB   (Ihandle *<strong>ih</strong>, const char* <strong>name</strong>, unsigned char *<strong>r</strong>, unsigned char *<strong>g</strong>, unsigned char *<strong>b</strong>);
void   IupGetRGBA  (Ihandle *<strong>ih</strong>, const char* <strong>name</strong>, unsigned char *<strong>r</strong>, unsigned char *<strong>g</strong>, unsigned char *<strong>b</strong>, unsigned char *<strong>a</strong>); (since 3.29)

int    IupGetIntId   (Ihandle*<strong> ih</strong>, const char*<strong> name</strong>, int <strong>id</strong>);          
float  IupGetFloatId (Ihandle*<strong> ih</strong>, const char*<strong> name</strong>, int <strong>id</strong><span class="style2">)</span>;
double IupGetDoubleId(Ihandle* <strong>ih</strong>, const char* <strong>name, </strong>int<strong> id</strong>);
void   IupGetRGBId   (Ihandle *<strong>ih</strong>, const char* <strong>name, </strong>int<strong> id</strong>, unsigned char *<strong>r</strong>, unsigned char *<strong>g</strong>, unsigned char *<strong>b</strong>);

int    IupGetIntId2   (Ihandle* <strong>ih</strong>, const char* <strong>name</strong>, int <strong>lin</strong>, int <strong>col</strong>);
float  IupGetFloatId2 (Ihandle* <strong>ih</strong>, const char* <strong>name</strong>, int <strong>lin</strong>, int <strong>col</strong>);
double IupGetDoubleId2(Ihandle* <strong>ih</strong>, const char* <strong>name, </strong>int<strong> lin, </strong>int<strong> col</strong>);
void   IupGetRGBId2   (Ihandle *<strong>ih</strong>, const char* <strong>name, </strong>int<strong> lin</strong>, int <strong>col</strong>, unsigned char *<strong>r</strong>, unsigned char *<strong>g</strong>, unsigned char *<strong>b</strong>);

[There is no equivalent in Lua]
</pre>
<p><strong>IupGetIntInt</strong> retrieves two integers separated by &#39;x&#39;, &#39;:&#39; 
or &#39;,&#39; and returns the number of returned values (0, 1 or 2). <strong>IupGetInt2</strong> 
returns just the second value.</p>
<h3>Notes</h3>

<p>See the <a href="../attrib_guide.html">Attributes Guide</a> for more details.</p>
<p>The returned value is not 
  necessarily the same pointer used by the application to define the attribute value.&nbsp;The pointers of internal IUP attributes 
  returned by <strong>IupGetAttribute</strong> should <b>never</b> be freed or changed, 
except when it is a custom application pointer that was stored using <strong>
IupSetAttribute</strong> and allocated by the application.</p>
<p>&nbsp;The returned pointer can be used safely even if <strong>IupGetGlobal</strong> 
or <strong>IupGetAttribute</strong> are called several times. But not too many 
times, because it is an internal buffer and after IUP may reuse it after around 
50 calls.</p>

<h4>IupLua</h4>

<p>In IupLua, only known internal pointer attributes are returned as <strong>user data</strong> 
or as an ihandle, all other attributes are returned as 
  strings. To access attribute data always as <strong>user data</strong> use iup.GetAttributeData:</p>

<pre>iup.GetAttributeData(<strong>ih</strong>: ihandle) -&gt; <strong>value</strong>: userdata [in Lua]</pre>

<h3>Examples</h3>

<p><a href="../../examples/">Browse for Example Files</a></p>

<h3>See Also</h3>

<p><a href="iupsetattribute.html">IupSetAttribute</a>, 
<a href="iupsetattributes.html">IupSetAttributes</a>,
  <a href="iupgethandle.html">IupGetHandle</a>, <a href="iupsetglobal.html">
IupSetGlobal</a>, <a href="iupgetglobal.html">IupGetGlobal</a></p>


</body>
</html>
